package cn.iocoder.yudao.module.pay.api.wallet;

import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.module.pay.api.wallet.dto.PayWalletTransactionCreateReqDTO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PayWalletTransactionApiImpl implements PayWalletTransactionApi {

    @Resource
    private PayWalletService payWalletService;

    @Override
    public void createWalletTransaction(PayWalletTransactionCreateReqDTO reqDTO) {
        // 获得用户钱包
        PayWalletDO walletDO = payWalletService.getOrCreateWallet(reqDTO.getUserId(), UserTypeEnum.MEMBER.getValue());

        payWalletService.addWalletBalance(walletDO.getId(), reqDTO.getBizId(), reqDTO.getBizType(), reqDTO.getPrice());
    }
}
